<script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script type="text/javascript" src="js/genunz.js" ></script>
<?php
if ((($_FILES["file"]["type"] == "text/plain"))
&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    //echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    //echo "Type: " . $_FILES["file"]["type"] . "<br />";
    //echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    $ran = rand () ;
    if (file_exists("test/" . $ran . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"], "test/" . $ran . $_FILES["file"]["name"]);
      $name = $ran . $_FILES["file"]["name"];
      echo"{ file : ".$name."}";
      //echo "<div id='upload_container'></div>";
      //echo "Stored in: " . "test/" . $name;
      }
    }
  }
else
  {
  echo "Invalid file " . $_FILES["file"]["size"];
  }
?> 
